const db = wx.cloud.database();
let notifyCollection = db.collection('notify');
Page({
  navgateToindex:function(){
    this.goToIndex();
  },
  request:function(){
    wx.requestSubscribeMessage({
      tmplIds: ['D6wOUVoU1VXScIxra0DxKiVXHe99VDOsLYLlrZtLPQ4'],
      success:res => {
        if (res['D6wOUVoU1VXScIxra0DxKiVXHe99VDOsLYLlrZtLPQ4']){
          notifyCollection.add({
            data:{
              tmpId:"D6wOUVoU1VXScIxra0DxKiVXHe99VDOsLYLlrZtLPQ4"
            }
          }).then(() => {
            this.goToIndex();
          });
        }
      },
      fail: console.error
    })
  },
  goToIndex(){
    wx.redirectTo({
      url: '../index/index',
    })
  }
})